const tools = {
	/**
	 * @description 详细判断是否为手机号
	 * @param {String} str 要匹配的手机号
	 * @returns {Boolean} 返回 匹配结果
	 */
	isPhone(str) {
		let reg = /^(0|86|17951)?1[0-9]{10}$/;
		if (reg.test(str)) {
			return true;
		} else {
			return false;
		}
	},

	isName(str) {
		let reg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,5}$/;
		if (reg.test(str)) {
			return true;
		} else {
			return false;
		}
	},
	// 页面加载处理
	loadIng(msg) {
		uni.showLoading({
			title: msg || '加载中....',
			mask: true
		})
		setTimeout(function() {
			uni.hideLoading();
		}, 1000)
	},
	showToast(msg) {
		uni.showToast({
			title: msg,
			duration: 4000,
			icon: 'none'
		})
	},
	hideLoading() {
		uni.hideLoading();
	},
	formatDate(timestamp,isS) {
		var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
		let Y = date.getFullYear() + '-';
		let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
		let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
		let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
		if(isS != 1){
			m = date.getMinutes() < 10 ? '0'+ date.getMinutes():date.getMinutes();
		}
		let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
		let reluset = ''
		if (isS == 1) {
			reluset = Y + M + D + h + m + s
		} else {
			reluset = Y + M + D + h + m
		}
		return reluset;
	},
	formatDay(timestamp){
		var date = new Date(timestamp* 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
		let Y = date.getFullYear() + '-';
		let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		let D = date.getDate() < 10 ? '0' + date.getDate(): date.getDate();
		let reluset = ''
		reluset=Y+M+D
		return reluset;
	}
}
export default tools;
